﻿<Window x:Class="MindTree.PerfWorkbench.Azure.Monitor.AzureMonitorConfig"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:src="clr-namespace:MindTree.PerfWorkbench.Azure.Monitor.AzureMonitor"
        xmlns:commandlib="clr-namespace:MindTree.PerfWorkbench.Azure.Monitor.CommandLib;assembly=AzureCommandLib"
        xmlns:core="clr-namespace:MindTree.PerfWorkbench.Azure.Monitor.Core;assembly=Core"
        Title="AzureMonitorConfig" Height="300" Width="300">
    <Window.Resources>
        
    </Window.Resources>
        <Grid>
        <Grid.Resources>
            <CollectionViewSource Source="{Binding Path=Azapp}" x:Key="cvs">
                <CollectionViewSource.SortDescriptions/>
                    <!--<scm:SortDescription PropertyName="Region" />
                    <scm:SortDescription PropertyName="State" />
                    <scm:SortDescription PropertyName="Sales" Direction="Descending" />
                </CollectionViewSource.SortDescriptions> -->
                <CollectionViewSource.GroupDescriptions>
                    <PropertyGroupDescription PropertyName="AppName" />
                    <PropertyGroupDescription PropertyName="RoleName" />
                </CollectionViewSource.GroupDescriptions>
            </CollectionViewSource>

            <BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter" />

            <Style TargetType="{x:Type ToggleButton}">
                <Setter Property="HorizontalContentAlignment" Value="Center" />
                <Setter Property="VerticalContentAlignment" Value="Center" />
                <Setter Property="Padding" Value="1" />
                <Setter Property="Height" Value="12" />
                <Setter Property="Width" Value="12" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ToggleButton}">
                            <Image x:Name="img" Source="icons\Collapse.png" />
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsChecked" Value="False">
                                    <Setter TargetName="img" Property="Source" Value="icons\Expand.png" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

        </Grid.Resources>
        <ListBox Padding="3.5" Grid.Row="1" Background="Black" ItemsSource="{Binding Source={StaticResource cvs}}" Margin="7">
            <ListBox.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="BurlyWood" />
                <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Chocolate" />
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="{x:Static SystemColors.ControlTextColor}" />
            </ListBox.Resources>
            <ListBox.GroupStyle>
                <GroupStyle>
                    <GroupStyle.ContainerStyle>
                        <Style TargetType="{x:Type GroupItem}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
                                        <ControlTemplate.Triggers>
                                            <DataTrigger Binding="{Binding Path=IsBottomLevel}" Value="True">
                                                <Setter TargetName="gridTemplate" Property="Grid.Background" Value="#FF965F00" />
                                            </DataTrigger>
                                        </ControlTemplate.Triggers>
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition />
                                                <RowDefinition />
                                            </Grid.RowDefinitions>
                                            <Grid Background="Black" x:Name="gridTemplate" Height="26" VerticalAlignment="Center">
                                                <Grid.Resources>
                                                    <Style TargetType="{x:Type TextBlock}">
                                                        <Setter Property="FontSize" Value="14" />
                                                        <Setter Property="Foreground" Value="White" />
                                                        <Setter Property="VerticalAlignment" Value="Center" />
                                                    </Style>
                                                </Grid.Resources>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto" />
                                                    <ColumnDefinition Width="*" />
                                                    <ColumnDefinition Width="45" />
                                                    <ColumnDefinition Width="30" />
                                                    <ColumnDefinition Width="110" />
                                                </Grid.ColumnDefinitions>

                                                <ToggleButton x:Name="btnShowHide" IsChecked="True" Margin="3.5" />

                                                <TextBlock Grid.Column="1" Text="{Binding Path=RoleInstanceId}" Margin="3.5,0" />
                                                <TextBlock Grid.Column="2" Text="Count:" />
                                                <!--<TextBlock Grid.Column="3" Text="{Binding Path=ItemCount}" TextAlignment="Right" Margin="0,0,11,0" />-->
                                                <!--<TextBlock Grid.Column="4" Text="{Binding StringFormat=\{0:C\}, Converter={StaticResource groupItemSalesSubtotalConverter}}" TextAlignment="Right" />-->
                                            </Grid>

                                            <ItemsPresenter Visibility="{Binding ElementName=btnShowHide, Path=IsChecked, Converter={StaticResource booleanToVisibilityConverter}}" Grid.Row="1" Margin="11,0,0,3.5" />

                                        </Grid>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </ListBox.GroupStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <DockPanel>
                        <TextBlock DockPanel.Dock="Right" HorizontalAlignment="Right" Text="{Binding Path=RoleInstanceId, StringFormat=C}" />
                        <TextBlock Text="{Binding Path=RoleName}" />
                    </DockPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</Window>
